package com.firewolf.fr.s009_exception;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;

/**
 * 空值处理
 * 
 * @author liuxing
 *
 */
public class ExceptionHandlerDriver {
	public static void main(String[] args) throws TemplateException, IOException {

		Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
		cfg.setDirectoryForTemplateLoading(new File("ftl"));
		cfg.setTemplateExceptionHandler(new MyHandler());
//		cfg.setTemplateExceptionHandler(TemplateExceptionHandler.DEBUG_HANDLER );
		Template tl = cfg.getTemplate("009_exception.ftl");
//		Writer w = new OutputStreamWriter(System.out);// 把数据显示到控制台

		// 指定输出文件路径
		Writer w = new FileWriter("html/009_exception.html");
		tl.process(null, w);
		w.flush();
	}
}
